package com.rui.study.micro.scheduler.config;

import com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: study_20180903
 * @description:
 * @author: Yaowr
 * @create: 2018-10-30 15:49
 **/
@Setter
@Configuration
@ConfigurationProperties(prefix = "elastic-job")
public class ElasticJobConfiguration {

    private String serverList;
    private String namespace;

    @Bean
    public ZookeeperConfiguration zookeeperConfiguration() {
        return new ZookeeperConfiguration(serverList, namespace);
    }

    @Bean(initMethod = "init")
    public CoordinatorRegistryCenter createRegistryCenter(ZookeeperConfiguration zkConfig) {
        return new ZookeeperRegistryCenter(zkConfig);
    }

}
